<template>
  <div class="main-bar-view">
    <div class="logo">
      <el-image :src="logoImage" class="search-icon"></el-image>
    </div>
    <el-link style="font-size: 20px" @click="back" type="info">首页</el-link>
    <div class="right-view">
      <template v-if="store.custom_token">
        <el-dropdown>
          <a class="ant-dropdown-link">
            <el-image :src="AvatarIcon" class="self-img"></el-image>
          </a>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item @click="goUserCenter('/orderview')">
                订单中心
              </el-dropdown-item>
              <el-dropdown-item @click="goUserCenter('/userinfoEdit')">
                个人设置
              </el-dropdown-item>
              <el-dropdown-item>
                <a @click="quit()">退出</a>
              </el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
        <div>
          <span style="margin-left: -30px;line-height: 50px;font-weight: bold">{{store.custom_username ? store.custom_username : '尊敬的新用户'}}</span>
        </div>
      </template>
      <template v-else>
        <el-button class="login btn hidden-sm" @click="goLogin()">登录</el-button>
        <el-button class="login btn hidden-sm" @click="goLogin()">注册</el-button>
      </template>
    </div>
  </div>
</template>

<script setup>
import MessageIcon from '@/assets/images/message-icon.svg';
import logoImage from '@/assets/images/k-logo.png';
import AvatarIcon from '@/assets/images/avatar.png'
import {shopCustomStore} from '@/stores/modules/shop/index.js'
import useAdminrouter from "@/router/index.js";
import {ref} from 'vue'
import {
  GetCustomInfoMessageService,
} from '@/api/netshop/customInfoMessage.js'

const router = useAdminrouter
const store = shopCustomStore()
const keywordRef = ref()

let loading = ref(false)
let msgVisible = ref(false)
const goLogin = () =>{
  router.push({path:'/customlogin'})
}
const quit = () =>{
  store.CustomLogout()
}
const back = () =>{
  router.push({path:'/netshop'})
}
const goUserCenter = (menuName) => {
  router.push({path: menuName})
}
</script>

<style scoped>
.main-bar-view {
  position: fixed;
  top: 0;
  left: 0;
  height: 56px;
  width: 100%;
  background: #fff;
  border-bottom: 1px solid #cedce4;
  padding-left: 48px;
  z-index: 16;
  display: flex;
  flex-direction: row;
  align-items: center;
}

.logo {
  margin-right: 24px;
}

.logo img {
  width: 32px;
  height: 32px;
  cursor: pointer;
}

.search-icon {
  width:40px;
  margin: 7px 8px 0 0;
}

.right-view {
  padding-right: 106px;
  flex: 1;
  display: flex;
  flex-direction: row;
  gap: 40px;
  justify-content: flex-end;

  .username {
    height: 32px;
    line-height: 32px;
    text-align: center;
  }

  button {
    outline: none;
    border: none;
    cursor: pointer;
  }

  img {
    cursor: pointer;
  }

  .right-icon {
    position: relative;
    width: 34px;
    margin: 4px 4 0 4px;
    cursor: pointer;
    display: inline-block;
    font-size: 0;
  }
  .self-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    vertical-align: middle;
    cursor: pointer;
    margin-top: 10px;
  }

  .btn {
    background: #4684e2;
    font-size: 14px;
    color: #fff;
    border-radius: 32px;
    text-align: center;
    width: 50px;
    height: 32px;
    line-height: 32px;
    vertical-align: middle;
    margin-left: -20px;
  }
}
.msgicon{
  width: 60px;
  height: 60px;
}
.content-list {
  flex: 1;
}

.content-list .list-title {
  color: #152844;
  font-weight: 600;
  font-size: 18px;
  height: 48px;
  margin-bottom: 4px;
  border-bottom: 1px solid #cedce4;
}

</style>
